import { Column, Entity, ManyToOne } from 'typeorm';
import { DBColumns } from '../';
import { ArticleCategorySchema, ArticleSchema } from '../../schema';
import { ArticleCategory } from '../article_category/article_category';

@Entity('article')
export class Article extends DBColumns implements ArticleSchema {
  @Column({
    type: 'varchar',
    length: 50,
    nullable: false,
    default: null,
    comment: '文章标题',
  })
  articleName: string;

  @Column({
    type: 'varchar',
    length: 50,
    nullable: false,
    default: null,
    comment: '文章副标题',
  })
  articleSubName: string;

  @Column({
    type: 'varchar',
    length: 50,
    nullable: false,
    default: null,
    comment: '文章作者',
  })
  author: string;

  @Column({
    type: 'text',
    nullable: false,
    default: null,
    comment: '文章摘要',
  })
  intro: string;

  @Column({
    type: 'text',
    nullable: false,
    default: null,
    comment: '文章内容',
  })
  context: string;

  @Column({
    type: 'bool',
    nullable: false,
    default: false,
    comment: '文章是否禁用',
  })
  off: boolean;

  @ManyToOne(() => ArticleCategory, category => category.articles)
  category?: ArticleCategorySchema;
}
